package com.quyunshuo.module.home.activity.login

import android.util.Log
import com.quyunshuo.androidbaseframemvvm.base.mvvm.m.BaseRepository
import com.quyunshuo.androidbaseframemvvm.network.bean.ArticleListRes2
import com.quyunshuo.androidbaseframemvvm.network.HomeApiService
import com.quyunshuo.androidbaseframemvvm.network.bean.BaseResponse
import com.quyunshuo.androidbaseframemvvm.network.bean.UserInfo
import kotlinx.coroutines.delay
import javax.inject.Inject

/**
 * 首页M层
 *
 * @author Qu Yunshuo
 * @since 5/25/21 5:42 PM
 */
class LoginRepository @Inject constructor() : BaseRepository() {

    @Inject
    lateinit var mApi: HomeApiService

    suspend fun getData() = request<String> {
        delay(1000)
        emit("数据加载成功")
    }

    suspend fun login(username: String, pasword: String) =request<BaseResponse<UserInfo>>{
        var response = mApi.login(username,pasword)
        emit(response)
    }
    suspend fun listArticle(page:Int) =request<BaseResponse<ArticleListRes2>>{
        var response = mApi.listMyCollect(page)
        emit(response)
    }

}